package com.ywk.zzh.mongotest.aspect;

import com.ywk.zzh.mongotest.document.User;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Aspect
@Component
public class UpdateAspect {

    @Before("@annotation(com.ywk.zzh.mongotest.annotate.GenerateUpdate) && args(user)")
    private void generateBeforeUpdate(JoinPoint joinPoint, User user){
        user.setUpdateTime(LocalDateTime.now());
    }
}
